package com.hiwan.unions.activity.webView;

import android.annotation.SuppressLint;
import android.content.Context;
import android.webkit.WebSettings;

import com.hiwan.unions.activity.base.BaseWebView;

/**
 * Created by llg on 2016/4/11.
 */
@SuppressLint("SetJavaScriptEnabled")
public class WebViewMapActivity extends BaseWebView {
    private String this_lat, this_lng;

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (myWebView != null) {
            myWebView.removeAllViews();
            myWebView.destroy();
        }
    }

    @Override
    public void local() {
        super.local();
        bundle = getIntent().getExtras();
        myWebView.loadUrl(bundle.getString("url"));
        this_lat = bundle.getString("this_lat");
        this_lng = bundle.getString("this_lng");
    }

    @Override
    public void onViewCreateds() {
        super.onViewCreateds();
        WebSettings webSettings = myWebView.getSettings();
        //允许JS执行
        webSettings.setJavaScriptEnabled(true);
        //支持多种分辨率，需要js网页支持
        webSettings.setCacheMode(webSettings.LOAD_DEFAULT);
        webSettings.setDatabaseEnabled(true);
        String dir = this.getDir("database", Context.MODE_PRIVATE).getPath();
        //启用地理定位
        webSettings.setGeolocationEnabled(true);
        //设置定位的数据库路径
        webSettings.setGeolocationDatabasePath(dir);
        webSettings.setDomStorageEnabled(true);
    }

    @Override
    public void getDateMethod() {
        super.getDateMethod();
        myWebView.loadUrl("javascript:getMapLatAndLon('" + this_lat + "','" + this_lng + "')");

    }
}

